/**
 * 设计一个函数，传递一个对象和key，返回对应值
 */
function getValueByKey(obj:IClasses,key:string){
    // key ---> id name
    // keyof IClasses = ["id","name"]
    return obj[key as keyof IClasses]
}

interface IClasses{
    id:number,
    name:string
}

interface ITeacher {
    address:string,
    age:number,
    level:number
}

// keyof ITeacher --->[address,age,level]

const classes01:IClasses = {
    id:1,
    name:"10期"
}
const teacher01:ITeacher = {
    address:"",
    age:23,
    level:1
}
getValueByKey(classes01,"name")



function getValueByKey2<T>(obj:T,key:string){
    return obj[key as keyof T]
}

getValueByKey2<IClasses>(classes01,"id")
getValueByKey2<ITeacher>(teacher01,"mo")